<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block</title>
</head>

<body>
<?php
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
$sqlReport = "SELECT `district_id`,`district_name`,`block_id`,`block_name` FROM `tbl_lookup_location` where `district_id` = ".$distId." group by `block_id`";
$queryReport = mysql_query($sqlReport);

?>
<table border="0" width="800" cellspacing="0" cellpadding="0">
	<tr>
		<td bgcolor="#E9E9E9" height="26">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
	  <font face="Verdana" color="#224568">&nbsp;Block wise scheme wise water bill raised and revenue generated</font></span></td>
	</tr>
	
	<tr>
		<td bgcolor="#E9E9E9" height="56">
		<table border="1" width="800" cellspacing="0" cellpadding="0" height="61" bgcolor="#C5D8EB">
			<tr>
				
				<td width="121" rowspan="2" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Name of the Block</b></font></td>
				<td width="92" rowspan="2" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>Type of the Scheme</b></font></td>
				<td colspan="3" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>Water Bill Raised (Rs. Lakhs/annum)</b></font></td>
				<td colspan="3" align="center">				  <font style="font-size: 8.5pt" face="Verdana"><b>Revenue Generated (Rs. Lakhs/annum)</b></font></td>
				<td colspan="3" align="center">				  <font style="font-size: 8.5pt" face="Verdana"><b>Collection Efficiency (Rs. Lakhs/annum)</b></font></td>
			</tr>
			<tr>
			  <td width="67" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>2009-10</b></font></td>
		      <td width="67" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>2008-09</b></font></td>
		      <td width="67" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>2007-08</b></font></td>
		      <td width="67" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>2009-10</b></font></td>
		      <td width="67" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>2008-09</b></font></td>
		      <td width="67" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>2007-08</b></font></td>
		      <td width="67" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>2009-10</b></font></td>
		      <td width="67" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>2008-09</b></font></td>
		      <td width="67" align="center"><font style="font-size: 8.5pt" face="Verdana"><b>2007-08</b></font></td>
		  </tr>
		</table>		</td>
	</tr>
	<tr>
		<td>
		<table border="1" width="800" cellspacing="0" cellpadding="0" height="49" bordercolor="#C5D8EB" style="border: 1px solid #BBD1E8" bgcolor="#F9F9F9">
		<?php
		
			while($rowReport = mysql_fetch_array($queryReport)) {
			$billPnT=getBillRaise($distId,'P&T',$rowReport['block_id'])+getBillRaise($distId,'TSS(P&T)',$rowReport['block_id']);
			$billPiped=getBillRaise($distId,'Piped',$rowReport['block_id']);
			$billSanDig=getBillRaise($distId,'Sanitary Diggs',$rowReport['block_id']);
			//print_r($billPiped);exit;
			$T1=number_format($billPnT[0]+$billPiped[0]+$billSanDig[0], 2, '.',''); 
			$GrandTotal1+=$T1;
			$T2=number_format($billPnT[1]+$billPiped[1]+$billSanDig[1], 2, '.','');
			$GrandTotal2+=$T2;
			$T3=number_format($billPnT[2]+$billPiped[2]+$billSanDig[2], 2, '.','');
			$GrandTotal3+=$T3;
			$T4=number_format($billPnT[3]+$billPiped[3]+$billSanDig[3], 2, '.','');
			$GrandTotal4+=$T4;
			$T5=number_format($billPnT[4]+$billPiped[4]+$billSanDig[4], 2, '.','');
			$GrandTotal5+=$T5;
			$T6=number_format($billPnT[5]+$billPiped[5]+$billSanDig[5], 2, '.','');
			$GrandTotal6+=$T6;
			?>
			<tr>
				<td width="105" align="center" rowspan="4" valign="top"><font style="font-size: 8.5pt" face="Verdana"><?php echo $rowReport['block_name']; ?></font></td>
				<td width="86" align="center">
				<font style="font-size: 8.5pt" face="Verdana">P &amp; T</font></td>
				<td align="center" width="69"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPnT[0], 2, '.','');?></font></td>
				<td align="center" width="62"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPnT[1], 2,'.', '');?></font></td>
				<td align="center" width="64"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPnT[2], 2,'.', '');?></font></td>
				<td align="center" width="69"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPnT[3], 2,'.', '');?></font></td>
				<td align="center" width="63"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPnT[4], 2,'.', '');?></font></td>
				<td align="center" width="63"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPnT[5],2, '.', '');?></font></td>
				<td width="63" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php 
				if($billPnT[3]==0)
				{
				echo "0.00";
				}else{
				echo $Total1=number_format($billPnT[0]/$billPnT[3], 2, '.','');}  ?></font></td>
			    <td width="63" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php 
				if($billPnT[4]==0)
				{
				echo "0.00";
				}else{
				echo $Total4=number_format($billPnT[1]/$billPnT[4], 2, '.','');}  ?></font></td>
			    <td width="69" align="center"><font style="font-size: 8.5pt" face="Verdana">
				<?php 
				if($billPnT[5]==0)
				{
				echo "0.00";
				}else{
				echo $Total7=number_format($billPnT[2]/$billPnT[5], 2, '.','');}  ?></font></td>
			</tr>
			<tr>
				<td width="86" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Piped</font></td>
				<td width="69" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPiped[0],2, '.', '');?></font></td>
				<td width="62" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPiped[1],2, '.', '');?></font></td>
				<td width="64" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPiped[2],2, '.', '');?></font></td>
				<td width="69" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPiped[3],2, '.', '');?></font></td>
				<td width="63" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPiped[4],2, '.', '');?></font></td>
				<td width="63" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billPiped[5],2, '.', '');?></font></td>
				<td align="center" width="63"><font style="font-size: 8.5pt" face="Verdana"><?php 
				if($billPiped[3]==0)
				{
				echo "0.00";
				}else{
				echo $Total2=number_format($billPiped[0]/$billPiped[3], 2, '.','');}
				?></font></td>
			    <td align="center" width="63"><font style="font-size: 8.5pt" face="Verdana"><?php 
				if($billPiped[4]==0)
				{
				echo "0.00";
				}else{
				echo $Total5=number_format($billPiped[1]/$billPiped[4], 2, '.','');}
				?></font></td>
			    <td align="center" width="69"><font style="font-size: 8.5pt" face="Verdana"><?php 
				if($billPiped[5]==0)
				{
				echo "0.00";
				}else{
				echo $Total8=number_format($billPiped[2]/$billPiped[5], 2, '.','');}
				?></font></td>
			</tr>
			<tr>
				<td width="86" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Sanitary Diggs</font></td>
				<td width="69" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billSanDig[0],2,'.','');?></font></td>
				<td width="62" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billSanDig[1],2,'.','');?></font></td>
				<td width="64" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billSanDig[2],2,'.','');?></font></td>
				<td width="69" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billSanDig[3],2,'.','');?></font></td>
				<td width="63" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billSanDig[4],2,'.','');?></font></td>
				<td width="63" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($billSanDig[5],2,'.','');?></font></td>
				<td align="center" width="63"><font style="font-size: 8.5pt" face="Verdana"><?php 
				if($billSanDig[3]==0)
				{
				echo "0.00";
				}else{
				echo $Total3=number_format($billSanDig[0]/$billSanDig[3], 2, '.','');}
				?></font></td>
			    <td align="center" width="63"><font style="font-size: 8.5pt" face="Verdana"><?php 
				if($billSanDig[4]==0)
				{
				echo "0.00";
				}else{
				echo $Total6=number_format($billSanDig[1]/$billSanDig[4], 2, '.','');}
				?></font></td>
			    <td align="center" width="69"><font style="font-size: 8.5pt" face="Verdana"><?php 
				if($billSanDig[5]==0)
				{
				echo "0.00";
				}else{
				echo $Total9=number_format($billSanDig[2]/$billSanDig[5], 2, '.','');}
				?></font></td>
			</tr>
			
			<tr>
				<td width="86" align="center" bgcolor="#E9E9E9">
				<font style="font-size: 8.5pt" face="Verdana"><b>Total</b></font></td>
				<td width="69" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $T1;  ?></b></font></td>
				<td width="62" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $T2;  ?></b></font></td>
				<td width="64" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $T3;  ?></b></font></td>
				<td width="69" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $T4;  ?></b></font></td>
				<td width="63" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $T5;  ?></b></font></td>
				<td width="63" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $T6;  ?></b></font></td>
				<td align="center" width="63" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php //echo $T7=$Total1+$Total2+$Total3; 
				if($T4==0)
				{
				echo "0.00";
				}else{
				echo number_format($T1/$T4, 2, '.','');}
				
				?></b></font></td>
			    <td align="center" width="63" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php //echo $T8=$Total4+$Total5+$Total6; 
				if($T5==0)
				{
				echo "0.00";
				}else{
				echo number_format($T2/$T5, 2, '.','');}
				?></b></font></td>
			    <td align="center" width="69" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php //echo $T9=$Total7+$Total8+$Total9; 
				if($T6==0)
				{
				echo "0.00";
				}else{
				echo number_format($T3/$T6, 2, '.','');}
				
				?></b></font></td>
			</tr>
			
			<?php
			$GrandTotal7+=$T7;
			$GrandTotal8+=$T8;
			$GrandTotal9+=$T9;
			}?>
			<tr>
				<td colspan="2" align="center" bgcolor="#E9E9E9">
				<font style="font-size: 8.5pt" face="Verdana"><b>Grand Total</b></font></td>
				<td width="69" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $GrandTotal1;  ?></b></font></td>
				<td width="62" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $GrandTotal2;  ?></b></font></td>
				<td width="64" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $GrandTotal3;  ?></b></font></td>
				<td width="69" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $GrandTotal4;  ?></b></font></td>
				<td width="63" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $GrandTotal5;  ?></b></font></td>
				<td width="63" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $GrandTotal6;  ?></b></font></td>
				<td width="63" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php //echo $GrandTotal7;  
				if($GrandTotal4==0)
				{
				echo "0.00";
				}else{
				echo number_format($GrandTotal1/$GrandTotal4, 2, '.','');}
				
				?></b></font></td>
				<td width="63" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php //echo $GrandTotal8;  
				if($GrandTotal5==0)
				{
				echo "0.00";
				}else{
				echo number_format($GrandTotal2/$GrandTotal5, 2, '.','');}
				?></b></font></td>
				<td width="69" align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php //echo $GrandTotal9;  
				if($GrandTotal6==0)
				{
				echo "0.00";
				}else{
				echo number_format($GrandTotal3/$GrandTotal6, 2, '.','');}
				?></b></font></td>
			</tr>
		</table>		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

</body>

</html>